import React, { Component } from 'react'

class Classfire extends Component {
  render() {
    return (
      <div>
          {
              this.timer = setInterval(()=>{
                console.log("111")
              },1000)
          }
      </div>
    )
  }
  componentWillUnmount(){
    clearInterval(this.timer);
}
}


export default class App extends Component {
  state = {
      type: false
  }
  render() {
    return (
      <div>
          <button onClick={()=>{
              this.setState({
                type: !this.state.type
              })
          }}>click</button>
        {this.state.type&&<Classfire></Classfire>}
      </div>
    )
  }
}
